this.BX=this.BX||{};this.BX.Landing=this.BX.Landing||{};this.BX.Landing.UI=this.BX.Landing.UI||{};(function(e,t,n,i,r,a,s,o,l,c,u,d,p,g,h,b,v,f){"use strict";var y,C;function m(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function k(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?m(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):m(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var L=function(){function e(t){babelHelpers.classCallCheck(this,e);this.options=k({},t);this.cache=new p.Cache.MemoryCache}babelHelpers.createClass(e,[{key:"setPresets",value:function e(t){this.presets=t;var n=this.getListContainer();p.Dom.clean(n);this.presets.forEach((function(e){p.Dom.append(e.getLayout(),n)}))}},{key:"getListContainer",value:function e(){return this.cache.remember("listContainer",(function(){return p.Tag.render(y||(y=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-presets-category-list"></div>\n\t\t\t'])))}))}},{key:"getLayout",value:function e(){var t=this;return this.cache.remember("layout",(function(){return p.Tag.render(C||(C=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-presets-category">\n\t\t\t\t\t<div class="landing-ui-presets-category-title">',"</div>\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),t.options.title,t.getListContainer())}))}}]);return e}();var P,B,O,T,H;function w(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?w(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):w(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var E={disabled:false,soon:false};var S=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this,e));n.setEventNamespace("BX.Landing.UI.Panel.BasePresetPanel.Preset");n.options=D(D({},E),e);n.cache=new p.Cache.MemoryCache;return n}babelHelpers.createClass(t,[{key:"getTextCrop",value:function e(){var t=this;return this.cache.remember("textCrop",(function(){return new c.TextCrop({rows:2,target:t.getDescriptionNode()})}))}},{key:"getIconNode",value:function e(){var t=this;return this.cache.remember("iconNode",(function(){return p.Tag.render(P||(P=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div\n\t\t\t\t\tclass="landing-ui-panel-preset-icon"\n\t\t\t\t\tstyle="background-image: url(','?v2)"\n\t\t\t\t></div>\n\t\t\t'])),t.options.icon)}))}},{key:"getTitleNode",value:function e(){var t=this;return this.cache.remember("titleNode",(function(){return p.Tag.render(B||(B=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div\n\t\t\t\t\tclass="landing-ui-panel-preset-text-title"\n\t\t\t\t\ttitle="','"\n\t\t\t\t>',"</div>\n\t\t\t"])),p.Text.encode(t.options.title),t.options.title)}))}},{key:"getDescriptionNode",value:function e(){var t=this;return this.cache.remember("descriptionNode",(function(){return p.Tag.render(O||(O=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div\n\t\t\t\t\tclass="landing-ui-panel-preset-text-description"\n\t\t\t\t\ttitle="','"\n\t\t\t\t>',"</div>\n\t\t\t"])),p.Text.encode(t.options.description),t.options.description)}))}},{key:"activate",value:function e(){p.Dom.addClass(this.getLayout(),"landing-ui-panel-preset-active")}},{key:"deactivate",value:function e(){p.Dom.removeClass(this.getLayout(),"landing-ui-panel-preset-active")}},{key:"isActive",value:function e(){return p.Dom.hasClass(this.getLayout(),"landing-ui-panel-preset-active")}},{key:"getSoonLabel",value:function e(){return this.cache.remember("soonLabel",(function(){return p.Tag.render(T||(T=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-panel-preset-soon-label">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),l.Loc.getMessage("LANDING_UI_BASE_PRESET_PANEL_SOON_LABEL"))}))}},{key:"getLayout",value:function e(){var t=this;return this.cache.remember("layout",(function(){var e=function e(n){n.preventDefault();if(t.options.openable){t.activate()}t.emit("onClick")};var n=t.options.active?" landing-ui-panel-preset-active":"";var i=t.options.disabled?" landing-ui-disabled":"";return p.Tag.render(H||(H=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-panel-preset',"",'" onclick="','">\n\t\t\t\t\t','\n\t\t\t\t\t<div class="landing-ui-panel-preset-text">\n\t\t\t\t\t\t',"\n\t\t\t\t\t\t","\n\t\t\t\t\t</div>\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),n,i,e,p.Type.isStringFilled(t.options.icon)?t.getIconNode():"",p.Type.isStringFilled(t.options.title)?t.getTitleNode():"",p.Type.isStringFilled(t.options.description)?t.getDescriptionNode():"",t.options.soon?t.getSoonLabel():"")}))}}]);return t}(d.EventEmitter);var I;function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach((function(t){babelHelpers.defineProperty(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var N=function(e){babelHelpers.inherits(t,e);function t(e){var n;babelHelpers.classCallCheck(this,t);n=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this));n.setEventNamespace("BX.Landing.UI.Panel.FormSettingsPanel.ContentWrapper");n.options=X({},e);n.cache=new p.Cache.MemoryCache;n.items=new v.BaseCollection;n.onChange=n.onChange.bind(babelHelpers.assertThisInitialized(n));return n}babelHelpers.createClass(t,[{key:"addItem",value:function e(t){if(!this.items.includes(t)){this.items.add(t);t.subscribe("onChange",this.onChange)}p.Dom.append(t.getLayout(),this.getLayout())}},{key:"insertBefore",value:function e(t,n){if(!this.items.includes(t)){this.items.add(t);t.subscribe("onChange",this.onChange)}p.Dom.insertBefore(t.getLayout(),n.getLayout())}},{key:"getLayout",value:function e(){return this.cache.remember("wrapper",(function(){return p.Tag.render(I||(I=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-panel-form-settings-content-wrapper"></div>'])))}))}},{key:"getValue",value:function e(){var t=this.items.reduce((function(e,t){if(t instanceof f.BaseForm&&t.getLayout().parentElement){return X(X({},e),t.serialize())}return e}),{});return this.valueReducer(t)}},{key:"valueReducer",value:function e(t){return t}},{key:"onChange",value:function e(t){this.emit("onChange",t.getData())}},{key:"clear",value:function e(){p.Dom.clean(this.getLayout())}}]);return t}(d.EventEmitter);var F,M,U;var _=function(e){babelHelpers.inherits(t,e);function t(){var e;babelHelpers.classCallCheck(this,t);e=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(t).call(this));e.setEventNamespace("BX.Landing.UI.Panel.BasePresetPanel");p.Dom.addClass(e.layout,"landing-ui-panel-base-preset");p.Dom.addClass(e.overlay,"landing-ui-panel-base-preset-overlay");e.cache=new p.Cache.MemoryCache;e.onSidebarButtonClick=e.onSidebarButtonClick.bind(babelHelpers.assertThisInitialized(e));e.onSaveClick=e.onSaveClick.bind(babelHelpers.assertThisInitialized(e));e.onCancelClick=e.onCancelClick.bind(babelHelpers.assertThisInitialized(e));e.onPresetFieldClick=e.onPresetFieldClick.bind(babelHelpers.assertThisInitialized(e));e.onPresetClick=e.onPresetClick.bind(babelHelpers.assertThisInitialized(e));e.onChange=e.onChange.bind(babelHelpers.assertThisInitialized(e));e.appendFooterButton(e.getSaveButton());e.appendFooterButton(e.getCancelButton());p.Dom.append(e.getHeaderControlsContainer(),e.header);return e}babelHelpers.createClass(t,[{key:"enableToggleMode",value:function e(){this.cache.set("toggleMode",true);this.renderTo(this.getViewContainer())}},{key:"isToggleModeEnabled",value:function e(){return this.cache.get("toggleMode")===true}},{key:"disableOverlay",value:function e(){p.Dom.addClass(this.overlay,"landing-ui-panel-base-preset-disable-overlay")}},{key:"getViewContainer",value:function e(){return this.cache.remember("viewContainer",(function(){var e=r.PageObject.getRootWindow();return e.document.querySelector(".landing-ui-view-container")}))}},{key:"getViewWrapper",value:function e(){var t=this;return this.cache.remember("viewWrapper",(function(){return t.getViewContainer().querySelector(".landing-ui-view-wrapper")}))}},{key:"getSaveButton",value:function e(){var t=this;return this.cache.remember("saveButton",(function(){var e=new n.BaseButton("save_settings",{text:l.Loc.getMessage("BLOCK_SAVE"),onClick:t.onSaveClick,className:"ui-btn ui-btn-success",attrs:{title:l.Loc.getMessage("LANDING_TITLE_OF_SLIDER_SAVE")}});p.Dom.removeClass(e.layout,"landing-ui-button");return e}))}},{key:"onSaveClick",value:function e(){}},{key:"getCancelButton",value:function e(){var t=this;return this.cache.remember("cancelButton",(function(){return new n.BaseButton("cancel_settings",{text:l.Loc.getMessage("BLOCK_CANCEL"),onClick:t.onCancelClick,className:"landing-ui-button-content-cancel",attrs:{title:l.Loc.getMessage("LANDING_TITLE_OF_SLIDER_CANCEL")}})}))}},{key:"onCancelClick",value:function e(){}},{key:"appendSidebarButton",value:function e(n){babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"appendSidebarButton",this).call(this,n)}},{key:"onSidebarButtonClick",value:function e(t){var n=this;var i=this.sidebarButtons.getActive();if(i){i.deactivate()}t.getTarget().activate();p.Dom.addClass(this.content,"landing-ui-panel-base-preset-fade");this.showContentLoader();void this.getContent(t.getTarget().id).then((function(e){if(e){setTimeout((function(){p.Dom.removeClass(n.content,"landing-ui-panel-base-preset-fade");n.clearContent();n.hideContentLoader();e.subscribe("onChange",n.onChange);p.Dom.append(e.getLayout(),n.content)}),300)}else{p.Dom.removeClass(n.content,"landing-ui-panel-base-preset-fade");n.clearContent();n.hideContentLoader()}}))}},{key:"onChange",value:function e(t){}},{key:"getContent",value:function e(t){throw new Error("Must be implemented in child class")}},{key:"getHeaderControlsContainer",value:function e(){var t=this;return this.cache.remember("headerControlsContainer",(function(){return p.Tag.render(F||(F=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-panel-base-preset-header-controls">\n\t\t\t\t\t',"\n\t\t\t\t\t","\n\t\t\t\t</div>\n\t\t\t"])),t.getLeftHeaderControls(),t.getRightHeaderControls())}))}},{key:"getRightHeaderControls",value:function e(){return this.cache.remember("rightHeaderControls",(function(){return p.Tag.render(M||(M=babelHelpers.taggedTemplateLiteral(['<div class="landing-ui-panel-base-preset-header-controls-right"></div>'])))}))}},{key:"getLeftHeaderControls",value:function e(){var t=this;return this.cache.remember("leftHeaderControls",(function(){return p.Tag.render(U||(U=babelHelpers.taggedTemplateLiteral(['\n\t\t\t\t<div class="landing-ui-panel-base-preset-header-controls-left">\n\t\t\t\t\t',"\n\t\t\t\t</div>\n\t\t\t"])),t.getPresetField().getNode())}))}},{key:"getPresetField",value:function e(){var t=this;return this.cache.remember("presetField",(function(){return new i.PresetField({events:{onClick:t.onPresetFieldClick}})}))}},{key:"show",value:function e(n){if(this.isToggleModeEnabled()){var i=BX.Landing.UI.Panel.ContentEdit;if(i.showedPanel){i.showedPanel.hide()}var r=this.getViewWrapper();p.Dom.style(r,"transition","400ms margin ease");setTimeout((function(){p.Dom.style(r,"margin-left","880px")}))}return babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"show",this).call(this,n)}},{key:"hide",value:function e(){var n=this;var i=this.getViewWrapper();if(this.isToggleModeEnabled()){p.Dom.style(i,"margin-left",null)}return babelHelpers.get(babelHelpers.getPrototypeOf(t.prototype),"hide",this).call(this).then((function(){if(n.isToggleModeEnabled()){p.Dom.style(i,"transition",null)}}))}},{key:"enableTransparentMode",value:function e(){p.Dom.addClass(this.layout,"landing-ui-panel-mode-transparent")}},{key:"disableTransparentMode",value:function e(){p.Dom.removeClass(this.layout,"landing-ui-panel-mode-transparent")}},{key:"setCategories",value:function e(t){this.cache.set("categories",t);this.cache["delete"]("renderedPresets")}},{key:"getCategories",value:function e(){return this.cache.get("categories")}},{key:"setPresets",value:function e(t){var n=this;t.forEach((function(e){e.unsubscribe("onClick",n.onPresetClick);e.subscribe("onClick",n.onPresetClick)}));this.cache.set("presets",t);this.cache["delete"]("renderedPresets")}},{key:"getPresets",value:function e(){return this.cache.get("presets")}},{key:"setSidebarButtons",value:function e(t){var n=this;t.forEach((function(e){e.subscribe("onClick",n.onSidebarButtonClick)}));this.cache.set("sidebarButtons",t)}},{key:"getSidebarButtons",value:function e(){return this.cache.get("sidebarButtons")}},{key:"onPresetFieldClick",value:function e(){var t=this;this.clear();this.enableTransparentMode();this.getCategories().forEach((function(e){var n=t.getPresets().filter((function(t){return t.options.category===e.options.id}));e.setPresets(n);p.Dom.append(e.getLayout(),t.content);t.getPresets().forEach((function(e){e.getTextCrop().init()}))}))}},{key:"onPresetClick",value:function e(t){this.disableTransparentMode();this.applyPreset(t.getTarget())}},{key:"activatePreset",value:function e(t){var n=this.getPresets().find((function(e){return e.options.id===t}));var i=this.getPresetField();i.setLinkText(n.options.title);i.setIcon(n.options.icon);n.activate()}},{key:"applyPreset",value:function e(t){var n=this;this.clear();var i=this.getPresetField();i.setLinkText(t.options.title);i.setIcon(t.options.icon);var r=this.getSidebarButtons().filter((function(e){return t.options.items.includes(e.id)}));r.forEach((function(e){e.deactivate();n.appendSidebarButton(e)}));if(p.Type.isStringFilled(t.options.defaultSection)){var a=r.find((function(e){return e.id===t.options.defaultSection}));if(a){a.activate();a.layout.click()}}else{var s=babelHelpers.slicedToArray(r,1),o=s[0];o.activate();o.layout.click()}}},{key:"getContentLoader",value:function e(){var t=this;return this.cache.remember("contentLoader",(function(){return new u.Loader({target:t.body,offset:{left:"130px"}})}))}},{key:"showContentLoader",value:function e(){void this.getContentLoader().show()}},{key:"hideContentLoader",value:function e(){void this.getContentLoader().hide()}}]);return t}(t.Content);e.BasePresetPanel=_;e.PresetCategory=L;e.Preset=S;e.ContentWrapper=N})(this.BX.Landing.UI.Panel=this.BX.Landing.UI.Panel||{},BX.Landing.UI.Panel,BX.Landing.UI.Button,BX.Landing.UI.Field,BX.Landing,BX.Landing.UI.Button,BX,BX,BX.Landing,BX.UI,BX,BX.Event,BX,BX.Landing.UI.Card,BX.Landing.UI.Card,BX.Landing.UI.Form,BX.Landing.Collection,BX.Landing.UI.Form);
//# sourceMappingURL=basepresetpanel.bundle.map.js